package com.cande.loki.exercise.testspring;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @auther ROCK CODER
 * @DATE 2022/3/13 9:44
 * @Description
 */
public class ImportMethod3 implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry, BeanNameGenerator importBeanNameGenerator) {
        RootBeanDefinition rootBeanDefinition = new RootBeanDefinition(User2.class);
        registry.registerBeanDefinition("hhhh",rootBeanDefinition);
        String aa =   importBeanNameGenerator.generateBeanName(rootBeanDefinition,registry);
        registry.registerBeanDefinition(aa,rootBeanDefinition);
        //todo 第三个参数好像是用来生产bean得name，具体作用不太清楚
    }

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

    }
}
